package com.shanhai.log.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.shanhai.log.common.entity.ShanHaiInterfaceLog;
import com.shanhai.log.service.ShanhaiLogManagerService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Service;

@Service
public class ShanhaiLogManagerServiceImpl implements ShanhaiLogManagerService {

    //log4j日志工具
    private static Logger logger = LogManager.getLogger(ShanhaiLogManagerServiceImpl.class);

    @Override
    public void defaultSaveShanhaiLog(ShanHaiInterfaceLog shanHaiInterfaceLog) {

        String jsonMessage = JSON.toJSONString(
                shanHaiInterfaceLog,
                SerializerFeature.PrettyFormat,
                SerializerFeature.WriteMapNullValue,
                SerializerFeature.WriteDateUseDateFormat
        );
        logger.info(jsonMessage);
    }

}
